package com.kust.tarvelService.controller;


import cn.kust.microtourismcommon.pojo.dto.ResponseResult;
import com.kust.tarvelService.pojo.ArticleCategory;
import com.kust.tarvelService.pojo.ArticleTag;
import com.kust.tarvelService.service.ArticleCategoryService;
import com.kust.tarvelService.service.ArticleTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 标签管理表 前端控制器
 * </p>
 *
 * @author mq
 * @since 2022-07-26
 */
@RestController
@RequestMapping("/tarvelService/article-tag")
public class ArticleTagController {

    @Autowired
    private ArticleTagService tagService;


    @GetMapping("/listCategory")
    public ResponseResult listCategory(){
        List<ArticleTag> list = tagService.list();
        return ResponseResult.success().setData(list);
    }

    @PostMapping("/addCategory")
    public ResponseResult addCategory(@RequestBody ArticleTag tag){
        tagService.save(tag);
        return ResponseResult.success();
    }

    @DeleteMapping("/{id}")
    public ResponseResult delCategory(@PathVariable("id") Long id){
        boolean b = tagService.removeById(id);
        if(b){
            return ResponseResult.success();
        }
        return ResponseResult.fail(500,"删除标签失败");
    }


}

